<template>
  <div class="app-container">
    <el-tabs v-model="activeName"  type="card" @tab-click="handleClick">
      <el-tab-pane label="待支付" name="0"></el-tab-pane>
      <el-tab-pane label="待处理" name="1"></el-tab-pane>
      <el-tab-pane label="进行中" name="2"></el-tab-pane>
      <el-tab-pane label="已注册" name="3"></el-tab-pane>
      <el-tab-pane label="无效" name="4"></el-tab-pane>
    </el-tabs>
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="申请类型" prop="trademarkApplyType">
        <el-select v-model="queryParams.trademarkApplyType" @change="sqlxChange" placeholder="请选择申请类型" clearable size="small">
          <el-option
            v-for="dict in trademarkApplyTypeOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="类目" prop="trademarkLeimu">
        <el-input
          v-model="queryParams.trademarkLeimu"
          placeholder="请输入类目"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="商标类型" prop="trademarkType">
        <el-select v-model="queryParams.trademarkType"  placeholder="请选择商标类型" clearable size="small" style="width: 100%;">
          <el-option
            v-for="dict in trademarkTypeOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
      <el-form-item>
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="primary"
              icon="el-icon-plus"
              size="mini"
              @click="handleAdd"
              v-hasPermi="['web:trademark:add']"
            >新增
            </el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="success"
              icon="el-icon-edit"
              size="mini"
              :disabled="single"
              @click="handleUpdate"
              v-hasPermi="['web:trademark:edit']"
            >修改
            </el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="danger"
              icon="el-icon-delete"
              size="mini"
              :disabled="multiple"
              @click="handleDelete"
              v-hasPermi="['web:trademark:remove']"
            >删除
            </el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="warning"
              icon="el-icon-download"
              size="mini"
              @click="handleExport"
              v-hasPermi="['web:trademark:export']"
            >导出
            </el-button>
          </el-col>
        </el-row>
      </el-form-item>
    </el-form>



    <el-table v-loading="loading" :data="trademarkList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center"/>
      <el-table-column label="申请信息" align="left" width="180">
        <template slot-scope="scope">
          <el-popover trigger="hover" placement="top">
            <p>申请类型: <span v-if="scope.row.trademarkApplyType == '0'">公司</span><span v-if="scope.row.trademarkApplyType != '0'">个人</span></p>
            <p>名称: {{ scope.row.trademarkCompanyName }} {{ scope.row.trademarkSqrxing }} {{ scope.row.trademarkSqrming }}</p>
            <p>邮箱: {{ scope.row.trademarkEmail }}</p>
            <p>国家: {{ scope.row.trademarkCounty }}</p>
            <p>邮编: {{ scope.row.trademarkYoubian }}</p>
            <p>省市区: {{ scope.row.trademarkProvince }}{{ scope.row.trademarkCity }}{{ scope.row.trademarkArea }}</p>
            <p>详细地址: {{ scope.row.trademarkAddress }}</p>
            <div slot="reference" class="name-wrapper">
              <el-tag size="medium">{{ scope.row.trademarkCompanyName }} {{ scope.row.trademarkSqrxing }} {{ scope.row.trademarkSqrming }}</el-tag>
            </div>
          </el-popover>
        </template>
      </el-table-column>
      <!--      <el-table-column label="申请类型" align="center" prop="trademarkApplyType" :formatter="trademarkApplyTypeFormat" />-->
      <!--      <el-table-column label="申请人名" align="center" prop="trademarkSqrming" />-->
      <!--      <el-table-column label="申请人姓" align="center" prop="trademarkSqrxing" />-->
      <!--      <el-table-column label="公司名称" align="center" prop="trademarkCompanyName" />-->
      <!--      <el-table-column label="邮箱" align="center" prop="trademarkEmail" />
            <el-table-column label="国家" align="center" prop="trademarkCounty" />
            <el-table-column label="邮编" align="center" prop="trademarkYoubian" />
            <el-table-column label="省市区" align="center">
              <template slot-scope="scope">
                {{ scope.row.trademarkProvince }}{{ scope.row.trademarkCity }}{{ scope.row.trademarkArea }}
              </template>
            </el-table-column>
            <el-table-column label="详细地址" align="center" prop="trademarkAddress" />-->
      <el-table-column label="商标类型" align="center" prop="trademarkType" :formatter="trademarkTypeFormat"/>
      <el-table-column label="商标信息" align="left" width="200">
        <template slot-scope="scope">
          <el-image
            style="width:40px;height: 40px;"
            :src="scope.row.trademarkPic"
            :preview-src-list="[scope.row.trademarkPic]"/>
          <br>
          <span v-if="scope.row.trademarkContent">内容：{{ scope.row.trademarkContent }}</span>
        </template>
      </el-table-column>
      <el-table-column label="类目" align="left" prop="trademarkLeimu" width="180">
        <template slot-scope="scope">
          <span>{{ scope.row.trademarkLeimu }}</span>
        </template>
      </el-table-column>
      <el-table-column label="价格" align="center" prop="trademarkMoney"/>
      <el-table-column label="支付状态" align="center" prop="trademarkPayStatus"/>
      <el-table-column label="支付时间" align="center" prop="trademarkPayTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.trademarkPayTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="审核状态" align="center" prop="trademarkStatus" :formatter="trademarkStatusFormat"/>

      <el-table-column label="文件信息" align="center" prop="patentFile1">
        <template slot-scope="scope">
          <span style="color: #00afff;cursor: pointer;" @click="wjxxMethod(scope.row)">查看</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['web:trademark:edit']"
          >修改
          </el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['web:trademark:remove']"
          >删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改商标对话框 -->
    <el-dialog
      :title="title"
      :visible.sync="open"
      width="600px"
      append-to-body
      :close-on-click-modal="false"
      v-dialogDrag
      class="my_dialog">
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="申请类型" prop="trademarkApplyType">
          <el-select v-model="form.trademarkApplyType" @change="sqlxChange" placeholder="请选择申请类型" style="width: 100%;">
            <el-option
              v-for="dict in trademarkApplyTypeOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item v-show="showCompany" label="公司名称" prop="trademarkCompanyName">
          <el-input v-model="form.trademarkCompanyName" placeholder="请输入公司名称"/>
        </el-form-item>
        <el-row v-show="showUser">
          <el-col :span="12">
            <el-form-item label="申请人姓" prop="trademarkSqrxing">
              <el-input v-model="form.trademarkSqrxing" placeholder="请输入申请人姓"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="申请人名" prop="trademarkSqrming">
              <el-input v-model="form.trademarkSqrming" placeholder="请输入申请人名"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="邮箱" prop="trademarkEmail">
          <el-input v-model="form.trademarkEmail" placeholder="请输入邮箱"/>
        </el-form-item>
        <el-form-item label="国家" prop="trademarkCounty">
          <el-input v-model="form.trademarkCounty" placeholder="请输入国家"/>
        </el-form-item>
        <el-form-item label="邮编" prop="trademarkYoubian">
          <el-input v-model="form.trademarkYoubian" placeholder="请输入邮编"/>
        </el-form-item>
        <el-form-item label="省市区">
          <SelectSsx v-model="form.selectOption1" style="width: 100%;"/>
        </el-form-item>
        <el-form-item label="详细地址" prop="trademarkAddress">
          <el-input v-model="form.trademarkAddress" placeholder="请输入详细地址"/>
        </el-form-item>

        <el-form-item label="商标类型" prop="trademarkType">
          <el-select v-model="form.trademarkType" @change="sblxChange" placeholder="请选择商标类型" style="width: 100%;">
            <el-option
              v-for="dict in trademarkTypeOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            ></el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="图案" v-show="showPic">
          <uploadImage v-model="form.trademarkPic"/>
        </el-form-item>
        <el-form-item label="内容" v-show="showWenzi">
          <el-input v-model="form.trademarkContent" type="textarea" placeholder="请输入内容"/>
        </el-form-item>
        <el-form-item label="类目" prop="trademarkLeimu">
          <el-input v-model="form.trademarkLeimuIds" v-show="false"/>
          <el-input v-model="form.trademarkLeimu" readonly="readonly" @click.native="selectEjml" placeholder="请输入国家"/>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>


    <!-- 平台上传图片 -->
    <el-dialog
      :title="wjxxTitle"
      :visible.sync="wjxxOpen"
      width="500px"
      append-to-body
      :close-on-click-modal="false"
      v-dialogDrag
      class="my_dialog">
      <el-form ref="form" :model="form" size="mini" label-width="68px">
        <el-tabs type="card">
          <el-tab-pane label="注册证书">
            <el-form-item label="注册证书">
              <single-upload v-model="form.trademarkFile1" @input="onInput()"/>
            </el-form-item>
            <!--  <el-image
                            style="height: 340px;"
                            :src="form.companyFile1"
                            :preview-src-list="[form.companyFile1]">
                            <single-upload v-model="form.otherFiles[index].qtwjPath" @input="onInput()"/>
                        </el-image>-->
          </el-tab-pane>
          <el-tab-pane label="受理回执">
            <el-form-item label="受理回执">
              <single-upload v-model="form.trademarkFile2" @input="onInput()"/>
            </el-form-item>
            <!--            <el-image
                        style="height: 340px;"
                        :src="form.companyFile2"
                        :preview-src-list="[form.companyFile2]">
                      </el-image>-->
          </el-tab-pane>
          <el-tab-pane label="审查文件">
            <el-form-item label="审查文件">
              <single-upload v-model="form.trademarkFile3" @input="onInput()"/>
            </el-form-item>
            <!--            <el-image
                        style="height: 340px;"
                        :src="form.companyFile2"
                        :preview-src-list="[form.companyFile2]">
                      </el-image>-->
          </el-tab-pane>
          <el-tab-pane label="其他文件">
            <span style="color: #00afff;cursor: pointer;margin-bottom: 15px;" @click="addOtherFile()">添加</span>
            <div v-for="(item,index) in this.form.otherFiles" :key="index">
              <el-form-item label="文件名称">
                <el-input v-model="form.otherFiles[index].qtwjTitle" @input="onInput()" placeholder="请输入标题" style="width: 100%;"/>
              </el-form-item>
              <el-form-item label="文件说明">
                <el-input v-model="form.otherFiles[index].qtwjContent" @input="onInput()" type="textarea" placeholder="请输入内容"/>
              </el-form-item>
              <el-form-item>
                <span slot="label">
                  文件上传<br>
                  <span style="color: red;cursor: pointer;margin-bottom: 15px;" @click="deleteWj(index);">刪除</span>
                </span>
                <single-upload v-model="form.otherFiles[index].qtwjPath" @input="onInput()"/>
              </el-form-item>
            </div>
          </el-tab-pane>
        </el-tabs>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFile">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>





    <el-dialog
      :title="ejmlTitle"
      :visible.sync="ejmlOpen"
      width="1000px"
      append-to-body
      :close-on-click-modal="false"
      v-dialogDrag
      class="my_dialog">

      <el-table v-loading="loading1" :data="sbejlmList" @selection-change="handleEjmlSelectionChange">
        <el-table-column type="selection" width="55" align="center"/>
        <el-table-column label="类目" align="center" prop="ejlmTitle"/>
        <!--        <el-table-column label="选择的价格" align="center" prop="ejlmPrice" />-->
        <el-table-column label="中文介绍" align="center" prop="ejlmContentZw"/>
        <el-table-column label="英文介绍" align="center" prop="ejlmContentYw"/>
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="100">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              icon="el-icon-edit"
              @click="handleUpdate(scope.row)"
              v-hasPermi="['web:sbejlm:edit']"
            >修改
            </el-button>
            <el-button
              size="mini"
              type="text"
              icon="el-icon-delete"
              @click="handleDelete(scope.row)"
              v-hasPermi="['web:sbejlm:remove']"
            >删除
            </el-button>
          </template>
        </el-table-column>
      </el-table>

      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryEjmlParams.pageNum"
        :limit.sync="queryEjmlParams.pageSize"
        @pagination="getEjmlList"
      />
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="cancelXzml">确 定</el-button>
        <el-button @click="cancelXzml">取 消</el-button>
      </div>
    </el-dialog>


  </div>
</template>

<script>
import {listTrademark, getTrademark, delTrademark, addTrademark, updateTrademark, exportTrademark, getShangBiaoLeiMu} from "@/api/sbxm/trademark/trademark";
import UploadImage from '@/components/UploadImage';
import Editor from '@/components/Editor';
import SelectSsx from "../../../components/SelectSsx";
import SingleUpload from "../../../components/UploadImage/singleUpload";
import {listSbejlm} from "../../../api/sbxm/sbejlm/sbejlm";

export default {
  name: "Trademark",
  components: {
    SingleUpload,
    SelectSsx,
    UploadImage,
    Editor,
  },
  data() {
    return {
      activeName: "0",
      options: [],
      // 二级类目表格数据
      sbejlmList: [],
      loading1: false,
      ejmlTitle: "",
      ejmlOpen: false,
      showUser: false,
      showCompany: false,
      showPic:false,
      showWenzi:false,


      wjxxOpen: false,
      wjxxTitle: "",

      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],

      ejmlids: [],

      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 商标表格数据
      trademarkList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 申请类型字典
      trademarkApplyTypeOptions: [],
      // 审核状态字典
      trademarkStatusOptions: [],
      // 商标类型字典
      trademarkTypeOptions: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        trademarkAddress: null,
        trademarkApplyType: null,
        trademarkArea: null,
        trademarkCity: null,
        trademarkCompanyName: null,
        trademarkContent: null,
        trademarkCounty: null,
        trademarkEmail: null,
        trademarkLeimu: null,
        trademarkMoney: null,
        trademarkPayStatus: null,
        trademarkPayTime: null,
        trademarkPic: null,
        trademarkProvince: null,
        trademarkSqrming: null,
        trademarkSqrxing: null,
        trademarkStatus: "0",
        trademarkType: null,
      },
      queryEjmlParams: {
        pageNum: 1,
        pageSize: 10,
      },
      // 表单参数
      form: {
        selectOption1: {},
        lmsz: []
      },
      // 表单校验
      rules: {}
    };
  },
  created() {
    this.getList();
    // this.getMl();
    this.getDicts("applyTypeCode").then(response => {
      this.trademarkApplyTypeOptions = response.data;
    });
    this.getDicts("trademarkStatusCode").then(response => {
      this.trademarkStatusOptions = response.data;
    });
    this.getDicts("sbCode").then(response => {
      this.trademarkTypeOptions = response.data;
    });
  },
  methods: {

    /** 查询二级类目列表 */
    getEjmlList() {
      this.loading1 = true;
      listSbejlm(this.queryEjmlParams).then(response => {
        this.sbejlmList = response.rows;
        this.total = response.total;
        this.loading1 = false;
      });
    },

    selectEjml(){
      this.ejmlTitle = "选择目录";
      this.ejmlOpen = true;
      this.getEjmlList();
    },

    /** 查询商标列表 */
    getList() {
      this.loading = true;
      listTrademark(this.queryParams).then(response => {
        this.trademarkList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },

    handleClick(e){
      this.activeName = e.index;
      this.queryParams.trademarkStatus = e.index;
      this.getList();
    },

    sqlxChange(e) {
      if (e == "0") {
        this.showCompany = true;
        this.showUser = false;
      } else {
        this.showCompany = false;
        this.showUser = true;
      }
    },

    sblxChange(e) {
      if (e == "0") {
        this.showWenzi = true;
        this.showPic = false;
      } else if(e == "1"){
        this.showPic = true;
        this.showWenzi = false;
      } else{
        this.showPic = true;
        this.showWenzi = true;
      }
    },

    wjxxMethod(row) {
      getTrademark(row.id).then(response => {
        this.form = response.data;
        this.wjxxOpen = true;
        this.wjxxTitle = "查看商标信息";
      });
    },

    /** 保存文件 */
    submitFile() {
      this.$refs["form"].validate(valid => {
        console.log(this.selectOption1)
        if (valid) {
          updateTrademark(this.form).then(response => {
            if (response.code === 200) {
              this.msgSuccess("修改成功");
              this.wjxxOpen = false;
            }
          });
        }
      });
    },

    zzlm() {
      let lmcode = [];
      let lmcodequan = [];
      let lmlabel = [];
      let arra = this.$refs["cascader"].getCheckedNodes(true);

      if (arra.length > 0) {
        this.form.lmsz.forEach(obj => {
          f:for (var i = 0; i < arra.length; i++) {
            if (obj[1] == arra[i].data.value) {
              lmcode.push(arra[i].data.value)
              lmcodequan.push(arra[i].parent.value + "/" + arra[i].data.value)
              lmlabel.push(arra[i].parent.label + "/" + arra[i].data.label);
              break f;
            }
          }
        });
      }
      this.form.trademarkLeimuCode = lmcode.toString();
      this.form.trademarkLeimuCodequan = lmcodequan.toString()
      this.form.trademarkLeimu = lmlabel.toString()
    },
    getMl() {
      getShangBiaoLeiMu().then(response => {
        this.options = response.data;
      });
    },
    // 申请类型字典翻译
    trademarkApplyTypeFormat(row, column) {
      return this.selectDictLabel(this.trademarkApplyTypeOptions, row.trademarkApplyType);
    },
    // 审核状态字典翻译
    trademarkStatusFormat(row, column) {
      return this.selectDictLabel(this.trademarkStatusOptions, row.trademarkStatus);
    },
    // 商标类型字典翻译
    trademarkTypeFormat(row, column) {
      return this.selectDictLabel(this.trademarkTypeOptions, row.trademarkType);
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.wjxxOpen = false;
      this.reset();
    },

    cancelXzml(){
      this.ejmlOpen = false;
    },

    // 表单重置
    reset() {
      this.form = {
        beginTime: null,
        createBy: null,
        createTime: null,
        endTime: null,
        remark: null,
        searchValue: null,
        updateBy: null,
        updateTime: null,
        trademarkAddress: null,
        trademarkApplyType: null,
        trademarkArea: null,
        trademarkCity: null,
        trademarkCompanyName: null,
        trademarkContent: null,
        trademarkCounty: null,
        trademarkEmail: null,
        trademarkLeimu: null,
        trademarkMoney: null,
        trademarkPayStatus: null,
        trademarkPayTime: null,
        trademarkPic: null,
        trademarkProvince: null,
        trademarkSqrming: null,
        trademarkSqrxing: null,
        trademarkStatus: "0",
        trademarkType: null,
        trademarkYoubian: null,
        trademarkFile1: null,
        trademarkFile2: null,
        trademarkFile3: null,
        selectOption1: {},
        lmsz: []
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },

    // 多选框选中数据
    handleEjmlSelectionChange(selection) {
      this.ejmlids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length

      let str = selection.map(item => item.yjlmTitle+"/"+item.ejlmTitle);

      this.form.trademarkLeimuIds = this.ejmlids.toString();
      this.form.trademarkLeimu = str.toString();

    },

    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加商标";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getTrademark(id).then(response => {
        this.form = response.data;
        if (this.form.trademarkCode != null && this.form.trademarkCode != '') {
          this.form.selectOption1 = {};
          this.form.selectOption1.code = this.form.trademarkCode;
          this.form.selectOption1.name = this.form.trademarkProvince + "," + this.form.trademarkCity + "," + this.form.trademarkArea;
        }
        if(this.form.trademarkApplyType == "0"){
          this.showCompany = true;
          this.showUser = false;
        }else{
          this.showCompany = false;
          this.showUser = true;
        }
        if(this.form.trademarkType != "1"){
          this.showWenzi = true;
        }
        if(this.form.trademarkType != "0"){
          this.showPic = true;
        }

        console.log(this.form)
        this.open = true;
        this.title = "修改商标";
      });
    },

    /** 查看证件 */
    addOtherFile() {
      console.log(this.form)
      if(!this.form.otherFiles){
        this.form.otherFiles=[]
      }
      this.form.otherFiles.push({qtwjTitle:"",qtwjPath:"",qtwjContent:"",objId: this.form.id});
      this.$forceUpdate();
    },

    deleteWj(index){
      this.form.otherFiles.splice(index,1);
      this.$forceUpdate();
      console.log(this.form.otherFiles)
    },


    onInput(){
      this.$forceUpdate();
    },

    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        console.log(this.selectOption1)
        if (this.form.selectOption1 != null) {
          this.form.trademarkCode = this.form.selectOption1.code;
          // var arras = this.form.selectOption1.name.split(",");
          // this.form.trademarkProvince = arras[0];
          // this.form.trademarkCity = arras[1];
          // this.form.trademarkArea = arras[2];
        }
        if(this.form.trademarkApplyType == '0'){
          this.form.trademarkSqrxing = "";
          this.form.trademarkSqrming = "";
        }
        if(this.form.trademarkApplyType == '1'){
          this.form.trademarkCompanyName = "";
        }
        if(this.form.trademarkType == "1"){
          this.form.trademarkContent = "";
        }
        if(this.form.trademarkType == "0"){
          this.form.trademarkPic = "";
        }
        if (valid) {
          if (this.form.id != null) {
            updateTrademark(this.form).then(response => {
              if (response.code === 200) {
                this.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              }
            });
          } else {
            addTrademark(this.form).then(response => {
              if (response.code === 200) {
                this.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              }
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$confirm('是否确认删除吗?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(function () {
        return delTrademark(ids);
      }).then(() => {
        this.getList();
        this.msgSuccess("删除成功");
      }).catch(function () {
      });
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有商标数据项?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(function () {
        return exportTrademark(queryParams);
      }).then(response => {
        this.download(response.msg);
      }).catch(function () {
      });
    }
  }
};
</script>
